package net.zoneland.knowledge.dao;

import java.util.List;
import net.zoneland.knowledge.model.LoginLog;
import net.zoneland.knowledge.model.LoginLogExample;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface LoginLogMapper {
    @SelectProvider(type=LoginLogSqlProvider.class, method="countByExample")
    long countByExample(LoginLogExample example);

    @Insert({
        "insert into AITK_LOGIN_LOG (ID, USERID, ",
        "USERNAME, LOGINTIME, ",
        "LOGINFROM, SERVERIP, ",
        "CLIENTIP, ORGID, ",
        "COMPANY)",
        "values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, ",
        "#{userName,jdbcType=VARCHAR}, #{loginTime,jdbcType=TIMESTAMP}, ",
        "#{loginFrom,jdbcType=VARCHAR}, #{serverIp,jdbcType=VARCHAR}, ",
        "#{clientIp,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, ",
        "#{company,jdbcType=VARCHAR})"
    })
    int insert(LoginLog record);

    @InsertProvider(type=LoginLogSqlProvider.class, method="insertSelective")
    int insertSelective(LoginLog record);

    @SelectProvider(type=LoginLogSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR),
        @Result(column="USERID", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="USERNAME", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="LOGINTIME", property="loginTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="LOGINFROM", property="loginFrom", jdbcType=JdbcType.VARCHAR),
        @Result(column="SERVERIP", property="serverIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="CLIENTIP", property="clientIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="ORGID", property="orgId", jdbcType=JdbcType.VARCHAR),
        @Result(column="COMPANY", property="company", jdbcType=JdbcType.VARCHAR)
    })
    List<LoginLog> selectByExample(LoginLogExample example);

    @UpdateProvider(type=LoginLogSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") LoginLog record, @Param("example") LoginLogExample example);

    @UpdateProvider(type=LoginLogSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") LoginLog record, @Param("example") LoginLogExample example);
}
